Nginx 配置文件格式化,Nginx 配置美化工具 |
您所在的位置:网站首页 › nginx apif5 › Nginx 配置文件格式化,Nginx 配置美化工具 |
工具简介 Nginx 配置文件格式化工具,支持一键格式化(美化)Nginx 配置文件,格式化之后的配置有更好的阅读体验。本工具提供的格式化功能是在客户端浏览器完成的,不会把配置内容上传到服务器,因此,工具响应速度非常快。 支持的选项本工具支持 2 个格式化选项:代码缩进和大括号位置。 ![]() 支持如下 3 种缩进方式: 以 2 个空格缩进以 4 个空格缩进以 tab 方式缩进2、大括号的位置该选项决定了 Nginx 配置里面大括号的位置:在行尾或单独一行。默认是在行尾展示。 示例代码下面展示了使用本工具对 Nginx 配置进行格式化的效果。 原配置内容: server { #listen 80 default_server; listen 443 ssl; ssl_certificate ssl/nginx.crt; ssl_certificate_key ssl/nginx.key; server_name _; root /var/www/html; index index.html index.php; gzip on; gzip_disable "msie6"; gzip_comp_level 6; # gzip_comp_level 9; gzip_min_length 1100; gzip_buffers 16 8k; gzip_proxied any; # gzip_http_version 1.1; gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/json application/xml+rss; client_max_body_size 300M; location / { root /var/www/html/client; } location ~ \.php$ { try_files $uri =404; include fastcgi_params; fastcgi_pass unix:/run/php/php7.3-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PHP_VALUE "upload_max_filesize=80M \n post_max_size=120M \n max_execution_time=200 \n max_input_time=200 \n memory_limit=256M"; } location ~* \.(css|js|less|html|ttf|woff|jpg|jpeg|gif|png|bmp|ico) { root /var/www/html/client; if (-f $request_filename) { break; } rewrite ^/img/([a-zA-Z_]*)/([a-zA-Z_]*)/([a-zA-Z0-9_\.]*)$ /server/php/image.php?size=$1&model=$2&filename=$3 last; add_header Cache-Control public; add_header Cache-Control must-revalidate; expires 7d; } }格式化之后: server { #listen 80 default_server; listen 443 ssl; ssl_certificate ssl/nginx.crt; ssl_certificate_key ssl/nginx.key; server_name _; root /var/www/html; index index.html index.php; gzip on; gzip_disable "msie6"; gzip_comp_level 6; # gzip_comp_level 9; gzip_min_length 1100; gzip_buffers 16 8k; gzip_proxied any; # gzip_http_version 1.1; gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/json application/xml+rss; client_max_body_size 300M; location / { root /var/www/html/client; } location ~ \.php$ { try_files $uri =404; include fastcgi_params; fastcgi_pass unix:/run/php/php7.3-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PHP_VALUE "upload_max_filesize=80M \n post_max_size=120M \n max_execution_time=200 \n max_input_time=200 \n memory_limit=256M"; } location ~* \.(css|js|less|html|ttf|woff|jpg|jpeg|gif|png|bmp|ico) { root /var/www/html/client; if (-f $request_filename) { break; } rewrite ^/img/([a-zA-Z_]*)/([a-zA-Z_]*)/([a-zA-Z0-9_\.]*)$ /server/php/image.php?size=$1&model=$2&filename=$3 last; add_header Cache-Control public; add_header Cache-Control must-revalidate; expires 7d; } }你可以使用上面提供的配置文件,亲自试一下。 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |